package org.halk.bio.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * 套接字服务端
 * <p>
 * socket客户端可以用telnet命令，telnet 127.0.0.1 8987
 * ctrl + ]
 * send  hello
 *
 * @Author zhuhao
 * @Date 2022/5/25 9:31
 * @desc
 */
public class SocketServer {

    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(8181);
        System.out.println("server 端上线，监听8181端口");
        Socket socket = serverSocket.accept();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String str = bufferedReader.readLine();
        System.out.println("收到客户端消息：" + str);
    }
}
